﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using daSyntaxAnalyser.SyntaxTree;
using CQLQueries.Analyzers;

namespace CQLQueries.SyntaxTree
{
    public class Expression2Node
    {
        public object NodeTree;
        public object ValueUp;
        public object ValueDown;

        public ExpressionNode Expression;
        public CQLTokens Op;

        public Expression2Node(CQLTokens Op1)
        {
            Op = Op1;
        }

        public void Visit()
        { 
            Expression.NodeTree = NodeTree;
            Expression.Visit();
            switch (Op)
            {
                case CQLTokens.Add:
                    ValueUp = Convert.ToDouble(ValueDown) + Convert.ToDouble(Expression.ValueUp);
                    break;
                case CQLTokens.Sub:
                    ValueUp = Convert.ToDouble(ValueDown) - Convert.ToDouble(Expression.ValueUp);
                    break;
            }
        }
    }
}
